package cn.edu.hunan.pm.controller;
import cn.edu.hunan.pm.Entity.Law;
import cn.edu.hunan.pm.service.LawService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/api/laws")
public class LawController {
    @Autowired
    private LawService lawService;

    @PostMapping
    public void addLaw(@RequestBody Law law) {
         lawService.addLaw(law);
    }

    @DeleteMapping("/{lawId}")
    public void deleteLawById(@PathVariable Integer lawId) {
         lawService.deleteLawById(lawId);
    }

    @PutMapping
    public void updateLaw(@RequestBody Law law) {
         lawService.updateLaw(law);
    }

//    @GetMapping("/{lawId}")
//    public Law findLawById(@PathVariable Integer lawId) {
//        return lawService.findLawById(lawId);
//    }

    @GetMapping
    public List<Law> findAllLaws() {
        return lawService.findAllLaws();
    }
}
